<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/15 15:01
 * Desc: 会员常用联系人
 */
class Request_Api_V2_Member_Linkman extends Request_Api_V2_Base
{
    public function __construct($request_param)
    {
        parent::__construct($request_param);

        //自定义规则
        $this->validation->rule('mid',array('Rule_Member','need_member'));
    }

    public function list()
    {
        $this->rules = [
            ['pagesize', ['digit', $this->rule_min(1)]],
            ['page', ['digit', $this->rule_min(0)]],
        ];

        return $this;
    }

    public function show_info()
    {
        $this->rules = [
            ['id', ['not_empty', 'digit', $this->rule_min(1)]],
        ];

        return $this;
    }

    public function delete()
    {
        $this->rules = [
            ['id', ['not_empty', 'digit', $this->rule_min(1)]],
        ];

        return $this;
    }

    public function insert()
    {
        $this->rules = $this->edit_rule();

        return $this;
    }

    public function update()
    {
        $rules   = $this->edit_rule();
        $rules[] = ['id', ['not_empty', 'digit', $this->rule_min(1)]];

        $this->rules = $rules;

        return $this;
    }

    /**
     * 编辑规则
     * @return array[]
     */
    private function edit_rule()
    {
        $gender    = array('男', '女');
        $card_type = array("身份证", "护照", "港澳通行证", "台湾通行证", "军官证", "外国人永久居留证");

        return [
            ['linkman', ['not_empty']],
            ['mobile', ['not_empty', 'phone']],
            ['cardtype', [$this->rule_in_array($card_type)]],
            ['sex', ['not_empty', $this->rule_in_array($gender)]],
//            ['cardnumber_expire_date', [$this->rule_date_format('Y-m-d')]],
//            ['birth', [$this->rule_date_format('Y-m-d')]],
        ];

    }
}